package com.note.common.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
 * 用户Token实体类
 */
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("user_token")
public class UserToken extends BaseEntity {

    /**
     * Token ID
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 用户ID
     */
    private Long userId;

    /**
     * Token内容
     */
    private String token;

    /**
     * 设备类型：WEB/IOS/ANDROID/OTHER
     */
    private String deviceType;

    /**
     * 设备信息，如浏览器类型、设备型号等
     */
    private String deviceInfo;

    /**
     * 登录IP
     */
    private String loginIp;

    /**
     * Token过期时间
     */
    private LocalDateTime expiredAt;

    /**
     * 上次活跃时间
     */
    private LocalDateTime lastActiveAt;

    /**
     * 状态：0-已注销 1-正常
     */
    private Integer status;
    @Column(name = "created_at")

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 修正月份MM和小时HH的大小写
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") // 修正时区写法
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    @Schema(description = "创建时间", example = "2023-10-01T12:00:00")
    private LocalDateTime createdAt;

    @Column(name = "updated_at")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 修正月份MM和小时HH的大小写
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") // 修正时区写法
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新时间", example = "2023-10-01T12:00:00")
    private LocalDateTime updatedAt;
} 